from rest_framework import serializers

from .models import CourseCategory, Course, Teacher, Comment


class CourseCategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = CourseCategory
        fields = ['id', 'name']


class TeacherSerializer(serializers.ModelSerializer):
    class Meta:
        model = Teacher
        fields = ['id', 'name', 'title', 'image2', 'image', 'brief', 'state']


class CourseSerializer(serializers.ModelSerializer):
    teacher = TeacherSerializer()

    class Meta:
        model = Course
        fields = ['id', 'name', 'students', 'teacher', 'price','brief', 'sections', 'period', 'course_img','course_img2']


class CommentSerializer(serializers.ModelSerializer):
    # teacher = TeacherSerializer()

    class Meta:
        model = Comment
        fields = ['id', 'teacher', 'content', 'create_time']
        extra_kwargs = {
            'id': {'read_only': True},
            'create_time': {'read_only': True}
        }
